home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 21 / CU Amiga Magazine's Super CD-ROM 21 (1998)(EMAP Images)(GB)[!][issue 1998-04].iso / CUCD / Programming / VisualBuilder / source / HookFuncs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-11-10  |  4.3 KB  |  178 lines

  1. SAVEDS ULONG ASM ApplyChangesFunc(REG(a0) struct Hook *h,
  2.                                   REG(a2) Object *win,
  3.                                   REG(a1) ULONG *num)
  4. { Object *app, *actobj;
  5.         
  6.   get(win,MUIA_ApplicationObject,&app);
  7.   get(app,MUIA_UserData,&actobj);
  8.   
  9.   if(actobj != NULL)
  10.     ApplyChanges(actobj);
  11.   else
  12.     MUI_Request(app,win,0,"warning","*_Too bad","no active object.");
  13.  
  14.   return(0);
  15. }
  16.  
  17. SAVEDS ULONG ASM DisplayFunc(REG(a2) char **array,
  18.                              REG(a1) struct VBList *str)
  19. {
  20.   *array++ = str->Key;
  21.   *array = str->Value;
  22.   
  23.   return(0);
  24. }
  25.  
  26. SAVEDS ULONG ASM ConstructFunc(REG(a2) APTR pool,
  27.                                REG(a1) struct VBList *str)
  28. {
  29.   char *key, *value;
  30.   struct VBList *entry;
  31.   
  32.   if(key=AllocPooled(pool,strlen(str->Key)+1))
  33.     strcpy(key,str->Key);
  34.     
  35.   if(value=AllocPooled(pool,strlen(str->Value)+1))
  36.     strcpy(value,str->Value);
  37.     
  38.   if(entry=AllocPooled(pool,sizeof(struct VBList)))
  39.   { entry->Key = key;
  40.     entry->Value = value;
  41.   }
  42.  
  43.   return((ULONG)entry);
  44. }
  45.  
  46. SAVEDS ULONG ASM DestructFunc(REG(a2) APTR pool,
  47.                               REG(a1) struct VBList *entry)
  48.   FreePooled(pool,entry->Key,strlen(entry->Key)+1);
  49.   FreePooled(pool,entry->Value,strlen(entry->Value)+1);
  50.   FreePooled(pool,entry,sizeof(entry));
  51.   
  52.   return(0);
  53. }
  54.  
  55. SAVEDS ULONG ASM DeleteObjectFunc(REG(a0) struct Hook *h,
  56.                                   REG(a2) Object *win,
  57.                                   REG(a1) ULONG *num)
  58. { Object *app, *actobj;
  59.         
  60.   get(win,MUIA_ApplicationObject,&app);
  61.   get(app,MUIA_UserData,&actobj);
  62.   
  63.   if(actobj != NULL)
  64.     Group_Remove(actobj);
  65.   else
  66.     MUI_Request(app,win,0,"Could not delete object","*_Say what!","No active object.");
  67.  
  68.   return(0);
  69. }
  70.  
  71. SAVEDS ULONG ASM InsertWindowFunc(REG(a0) struct Hook *h,
  72.                                   REG(a2) Object *win,
  73.                                   REG(a1) ULONG *num)
  74.   Object *app;
  75.   int i;
  76.   
  77.   get(win,MUIA_ApplicationObject,&app);
  78.  
  79.   for(i=0;a->UserWin[i]!=NULL;i++);
  80.   
  81.   if(i<15)
  82.   { 
  83.     a->UserWin[i] = WindowObject,
  84.       MUIA_Window_Title, "NewWindow",
  85.       MUIA_Window_ID, MAKE_ID('W','I','N',i),
  86.       WindowContents, HGroup,
  87.         Child, DropGroupObject("Group1"),
  88.           Child, HSpace(0),
  89.         End,
  90.       End,
  91.     End;
  92.  
  93.     DoMethod(app,OM_ADDMEMBER,a->UserWin[i]);
  94.     set(a->UserWin[i],MUIA_Window_Open,TRUE);
  95.  
  96.     DoMethod(a->UserWin[i], MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
  97.              a->UserWin[i], 3, MUIM_Set, MUIA_Window_Open, FALSE);
  98.   }
  99.   else
  100.   { MUI_Request(app,win,0,"Warning","*_This sucks!",
  101.                 "Insert window:\nThe maximum amount of windows is 15!");
  102.   }
  103.  
  104.   return(0);
  105. }
  106.  
  107. SAVEDS ULONG ASM AboutVBFunc(REG(a0) struct Hook *h,
  108.                              REG(a2) Object *win,
  109.                              REG(a1) ULONG *num)
  110.   Object *app;
  111.   
  112.   get(win,MUIA_ApplicationObject,&app);
  113.  
  114.   MUI_Request(app,win,0,"About Visual Builder","*_Okido",
  115.                 "Visual builder v1.0 alpha\nWritten by Jan Klok.");
  116.  
  117.   return(0);
  118. }
  119.  
  120. SAVEDS ULONG ASM ObjStrFunc(REG(a0) struct Hook *h,
  121.                             REG(a2) Object *list,
  122.                             REG(a1) Object *str)
  123. {
  124.   struct VBList *x;
  125.  
  126.   DoMethod(list,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&x);
  127.   set(str,MUIA_String_Contents,x->Value);
  128.  
  129.   return(TRUE);
  130. }
  131.  
  132. SAVEDS ULONG ASM StrObjFunc(REG(a0) struct Hook *h,
  133.                             REG(a2) Object *list,
  134.                             REG(a1) Object *str)
  135. {
  136.   struct VBList *x;
  137.   char *s;
  138.   int i;
  139.  
  140.   get(str,MUIA_String_Contents,&s);
  141.  
  142.   for (i=0;;i++)
  143.   {
  144.     DoMethod(list,MUIM_List_GetEntry,i,&x);
  145.     if (!x)
  146.     {
  147.       set(list,MUIA_List_Active,MUIV_List_Active_Off);
  148.       break;
  149.     }
  150.     else if (!stricmp(x->Value,s))
  151.     {
  152.       set(list,MUIA_List_Active,i);
  153.       break;
  154.     }
  155.   }
  156.   return(TRUE);
  157. }
  158.  
  159. SAVEDS ULONG ASM ShowHideToolBarFunc(REG(a0) struct Hook *h,
  160.                                      REG(a2) Object *toolbar,
  161.                                      REG(a1) ULONG *visible)
  162.   if (DoMethod(a->MainWinGroup,MUIM_Group_InitChange))
  163.   { 
  164.     if(XGet(a->ViewToolbar,MUIA_Menuitem_Checked)) 
  165.       DoMethod(a->MainWinGroup,OM_ADDMEMBER,toolbar);
  166.     else
  167.       DoMethod(a->MainWinGroup,OM_REMMEMBER,toolbar);
  168.       
  169.     DoMethod(a->MainWinGroup,MUIM_Group_ExitChange);
  170.   }
  171.   return(0);
  172. }
  173.  
  174.